#include <iostream>
#include <ctime>

#define DBG_LEVEL 0
#define INF_LEVEL 1
#define ERR_LEVEL 2
#define DEFAULT_LEVEL DBG_LEVEL
#define LOG(level, format, ...)\
{\
    if(level >= DEFAULT_LEVEL)\
    {\
        time_t raw_time = time(nullptr);\
        struct tm* ptm = localtime(&raw_time);\
        char time_str[32];\
        strftime(time_str, 31, "%H-%M-%S", ptm);\
        printf("[%s][%s][%s:%d] " format "\n", #level, time_str, __FILE__, __LINE__, ##__VA_ARGS__);\
    }\
}
#define DLOG(format, ...) LOG(DBG_LEVEL, format, ##__VA_ARGS__)
#define ILOG(format, ...) LOG(INF_LEVEL, format, ##__VA_ARGS__)
#define ELOG(format, ...) LOG(ERR_LEVEL, format, ##__VA_ARGS__)
int main()
{
    DLOG("hello %s", "world");
    DLOG("hello world");

    ILOG("hello %s", "world");
    ILOG("hello world");

    ELOG("hello %s", "world");
    ELOG("hello world");
    return 0;
}
//##为了防止传空参数报错